#include "GoToLine.h"
#include <QtDebug>

GoToLine::GoToLine(QWidget* parent):QDialog(parent)
{
	ui.setupUi(this);
	setAttribute(Qt::WA_DeleteOnClose);
	connect(ui.OkBox,SIGNAL(clicked()),SLOT(JumpLineNum()));
	TextEdit = NULL;
}

GoToLine::~GoToLine(void)
{
}

void GoToLine::JumpLineNum(void)
{
	QString LineNumStr = ui.LineNum->text();
	if( LineNumStr.isEmpty())
	{
		QMessageBox::warning(this, SoftwareName,
                             tr("Line number is empty"));
		return ;
	}
	int LineNum = LineNumStr.toInt();
	LineNum-=1;
	Q_ASSERT(TextEdit!=NULL);
	TextEdit->setCursorPosition(LineNum,0);
	this->close();
}

void GoToLine::SetTextEdit(QsciScintilla* TextEdit)
{
	this->TextEdit = TextEdit;
}
